#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    cout << "Please enter a number between 0 and 9999" << endl;
    vector<string> unites = {"one", "ten", "hundred", "thousand"};
    string s;
    while (cin >> s)
    {
        try
        {
            int x = stoi(s);
            if (x < 0 || x > 9999)
            {
                throw out_of_range("");
            }
            cout << s << " is";
            for (int i = 0; i < s.size(); i++)
            {
                cout << s[i] << " " << unites[s.size() - 1 - i] << (s[i] > '1' ? "s" : "");
                cout << (i < s.size() - 1 ? " and " : "\n");
            }
        }
        catch (invalid_argument &)
        {
            std::cerr << "invalid nuymber" << '\n';
        }
        catch (out_of_range &)
        {
            cerr << "number nust be between 0 and 9999" << endl;
        }
    }
}